package com.utonw.carloan.fragment.applyloan;

import android.content.Intent;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView;

import com.sensetime.library.finance.ocr.card.IdCardInfo;
import com.utonw.carloan.R;
import com.utonw.carloan.fragment.BaseFragment;
import com.utonw.carloan.function.GlobalLoanFunction;
import com.utonw.carloan.utils.ChooseBarUtils;

import java.util.ArrayList;

/**
 * Created by SEELE on 2017/3/22.
 */

/**
 * 申请贷款流程4：车辆信息
 */
public class LoanStepFourFragment extends BaseFragment {

    //初始化全局方法
    private GlobalLoanFunction mGlobalLoanFunction;


    @Override
    public int setLayout() {
        return R.layout.fragment_applyloan_step_four;
    }

    @Override
    public void initView(View view) {

    }

    @Override
    public void initData() {

        //初始化PickerView选择器
        mGlobalLoanFunction = new GlobalLoanFunction();
        //设置ChooseBar标题
        ChooseBarUtils titleUtils = new ChooseBarUtils(getHoldingActivity()) {
            @Override
            protected void setChooseBarClickListener(int view) {

            }

            @Override
            protected void setChooseBarClickListener(int view, TextView toShow) {

                switch (view) {
                    case R.id.cheliangleixing:

                        final ArrayList<String> data1 = new ArrayList<>();
                        data1.add("轿车");
                        data1.add("跑车");
                        data1.add("SUV");
                        data1.add("MPV");
                        data1.add("商用车");
                        data1.add("其他");
                        mGlobalLoanFunction.setTempData(data1, toShow).oriPickerView(getContext());

                        break;

                    case R.id.chudengshijian:

                        mGlobalLoanFunction.setTempData(null, toShow).timePickerView(getContext());

                        break;


                }
            }

            @Override
            protected void getCheckedViewListener(int includeId, int sTitle, View toCheck) {
                setCheckViews(sTitle, toCheck);
            }

            @Override
            public void onToggleButtonListener(int buttonView, boolean isChecked) {

            }

            @Override
            public void getEditTextWithTipsListener(int includeId, EditText tempEt1) {

            }

            @Override
            public void onRadioButtonListener(RadioButton rMale, RadioButton rFemale) {

            }

            @Override
            public void onImageChooseBarListener(int view, ImageView mIndicator, TextView mInstruction, int sTitle) {

                switch (view) {
                    //行驶证副页
                    case R.id.xingshizhengfuye:
                        uploadImageData(mGlobalLoanFunction,mIndicator, mInstruction, sTitle);
                        break;
                    //车辆登记证
                    case R.id.cheliangdengjizheng:
                        uploadImageData(mGlobalLoanFunction,mIndicator, mInstruction, sTitle);
                        break;

                    //驾驶证
                    case R.id.jiashizheng:
                        uploadImageData(mGlobalLoanFunction,mIndicator, mInstruction, sTitle);
                        break;

                    //交强险保单
                    case R.id.jiaoqiangxianbaodan:
                        uploadImageData(mGlobalLoanFunction,mIndicator, mInstruction, sTitle);
                        break;

                    //商业险保单
                    case R.id.shangyexianbaodan:
                        uploadImageData(mGlobalLoanFunction,mIndicator, mInstruction, sTitle);
                        break;

                    //车钥匙
                    case R.id.cheyaoshi:
                        uploadImageData(mGlobalLoanFunction,mIndicator, mInstruction, sTitle);
                        break;


                }
            }

            @Override
            public void getChangeWordsEditTextListener(int includeId, EditText tempEt1, int sTitle) {

            }

            @Override
            public void setVerificationListener() {

            }
        };
        titleUtils.initChooseBar("10","0", "carLicensePlate", R.id.chepaihaoma, R.string.apply_page_four_car_num, ChooseBarUtils.ResultState.CHANGE_WORDS, "扫描自动识别");
        titleUtils.initChooseBar("11","0", "vehicleIdentification", R.id.VINcode, R.string.apply_page_four_VIN_code, ChooseBarUtils.ResultState.CHANGE_WORDS, "扫描自动识别");
        titleUtils.initChooseBar("12","0", "engineNo", R.id.fadongjihaoma, R.string.apply_page_four_eng_num, ChooseBarUtils.ResultState.CHANGE_WORDS, "扫描自动识别");
        titleUtils.initChooseBar("0","0", "vehicleType", R.id.cheliangleixing, R.string.apply_page_four_car_type);
        titleUtils.initChooseBar("9","0", "carBrand", R.id.cheliangpinpai, R.string.apply_page_four_car_brand, ChooseBarUtils.ResultState.CHANGE_WORDS, "请输入车辆品牌");
        titleUtils.initChooseBar("0","0", "carBuyDate", R.id.chudengshijian, R.string.apply_page_four_car_first_time);
        titleUtils.initChooseBar("0","0", "xingshizheng", R.id.xingshizhengfuye, R.string.apply_page_four_second_sheets, ChooseBarUtils.ResultState.ORI_WITH_IMAGE, null);
        titleUtils.initChooseBar("0","0", "dengjizheng", R.id.cheliangdengjizheng, R.string.apply_page_four_house_data, ChooseBarUtils.ResultState.ORI_WITH_IMAGE, null);
        titleUtils.initChooseBar("0","0", "jiashizheng", R.id.jiashizheng, R.string.apply_page_four_drivers_license, ChooseBarUtils.ResultState.ORI_WITH_IMAGE, null);
        titleUtils.initChooseBar("0","0", "insurancePolicy", R.id.jiaoqiangxianbaodan, R.string.apply_page_four_TCI, ChooseBarUtils.ResultState.ORI_WITH_IMAGE, null);
        titleUtils.initChooseBar("0","0", "businessInsurancePolicy", R.id.shangyexianbaodan, R.string.apply_page_four_CI, ChooseBarUtils.ResultState.ORI_WITH_IMAGE, null);
        titleUtils.initChooseBar("0","0", "cheyaoshi", R.id.cheyaoshi, R.string.apply_page_four_key_num, ChooseBarUtils.ResultState.ORI_WITH_IMAGE, null);

    }

    @Override
    protected void getIdcardFrontInfo(IdCardInfo idCardInfo) {

    }

    @Override
    protected void getIdcardBackInfo(IdCardInfo idCardInfo) {

    }

    @Override
    protected void getBankcardInfo(Intent cardData) {

    }

    @Override
    protected void getCreditcardInfo(Intent cardData) {

    }


}
